import 'package:flutter/material.dart';
import 'package:flutter_funiture_ui/models/product.dart';
import 'package:flutter_funiture_ui/screen/detail/detail_screen.dart';
import 'package:flutter_funiture_ui/screen/product/components/product_card.dart';
import 'package:flutter_funiture_ui/screen/product/components/search_bar.dart';
import 'package:animations/animations.dart';
import '../../../constants.dart';
import 'category_list.dart';

class Body extends StatefulWidget {
  const Body({Key key}) : super(key: key);

  @override
  _BodyState createState() => _BodyState();
}

class _BodyState extends State<Body> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      bottom: false,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          SearchBar(),
          CategoryList(),
          SizedBox(height: kDefaultPadding / 2),
          Expanded(
            child: Stack(
              children: [
                // our background
                Container(
                  margin: EdgeInsets.only(top: 70),
                  decoration: BoxDecoration(
                    color: kBackgroundColor,
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(40),
                      topRight: Radius.circular(40),
                    ),
                  ),
                ),
                // ProductCard(),
                ListView.builder(
                    physics: BouncingScrollPhysics(),
                    itemCount: products.length,
                    itemBuilder: (context, index) {
                      // return OpenContainer(
                      //   closedElevation: 0,
                      //   openElevation: 0,
                      //   openColor: Colors.transparent,
                      //   closedColor: Colors.transparent,
                      //   transitionDuration: Duration(milliseconds: 800),
                      //   closedBuilder: (context, action) =>
                      //       ProductCard(index: index, product: products[index]),
                      //   openBuilder: (context, action) =>
                      //       DetailScreen(product: products[index]),
                      // );
                      return ProductCard(
                          index: index,
                          product: products[index],
                          press: () {
                            Navigator.push(
                              context,
                              MaterialPageRoute(
                                builder: (context) => DetailScreen(
                                  product: products[index],
                                ),
                              ),
                            );
                          });
                    }),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
